/*
* Copyright 2011 Pavel Kozhin 
*
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed  under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*
* Author: Pavel Kozhin.
*/
package org.etherframework.core.reflection
{
	public final class Metatag
	{
		private var _name:String;
		private var _classMetadata:Vector.<Metadata>;
		private var _variables:Vector.<Variable>;
		private var _accessors:Vector.<Accessor>;
		private var _methods:Vector.<Method>;
		private var _allMembers:Vector.<MetadataMember>;
		
		public function Metatag(name:String, classMetadata:Vector.<Metadata>, 
								variables:Vector.<Variable>, accessors:Vector.<Accessor>, 
								methods:Vector.<Method>)
		{
			_name = name;
			_classMetadata = classMetadata;
			_variables = variables;
			_accessors = accessors;
			_methods = methods;
		}

		public function get name():String { return _name; }
		public function get methods():Vector.<Method> { return _methods; }
		public function get accessors():Vector.<Accessor> { return _accessors; }
		public function get variables():Vector.<Variable> { return _variables; }
		public function get classMetadata():Vector.<Metadata> { return _classMetadata; }
		public function get allMembers():Vector.<MetadataMember> 
		{ 
			if (!_allMembers && (_accessors || _methods || _variables))
			{
				var result:Vector.<MetadataMember> = new Vector.<MetadataMember>();
				
				if (_accessors)
					result = result.concat(_accessors);
				
				if (_methods)
					result = result.concat(_methods);
				
				if (_variables)
					result = result.concat(_variables);
				
				_allMembers = result;
			}
			
			return _allMembers; 
		}
		
	}
}